<%@ page import="javabean.*" %>
<%@ page import="java.util.List" %>
<%@ page import="DAO.BillDAO" %>
<%@ page import="DAO.DAOFactory" %>
<%@ page import="java.sql.SQLException" %><%--
  Created by IntelliJ IDEA.
  User: 32650
  Date: 2023-05-18
  Time: 2:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    List<Bill> billList = null;
    Customer loginCustomer = (Customer) session.getAttribute("loginCustomer");
    BillDAO billDAO = (BillDAO) DAOFactory.getBillDAOInstance();
    if (loginCustomer == null) {
        out.print("<script>alert('请先登录');window.location.href='Login.jsp'</script>");
    } else {
        try {
            billList = billDAO.getBillList(loginCustomer.getCustomerID());
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        if (billList == null) {
            out.print("<script>alert('您还没有账单');window.location.href='index.jsp'</script>");
        }
    }
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta
            name="viewport"
            content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
    />
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <link href="css/Bar.css" rel="stylesheet">
    <link href="css/Billing_Search.css" rel="stylesheet">
    <title>移动网上营业厅</title>
</head>
<body>
<div class="header">
    <h2>移动网上营业厅</h2>
</div>
<div class="content">
    <div class="left">
        <ul>
            <li><a href="Login.jsp">登录</a></li>
            <li><a href="Registration.jsp">注册</a></li>
            <li><a href="index.jsp">首页</a></li>
            <li><a href="Personal_Info.jsp">个人信息</a></li>
            <li><a href="MyPackage">我的套餐</a></li>
            <li><a href="Balance.jsp">查询余额</a></li>
            <li><a href="MyBill.jsp">查询账单</a></li>
            <li><a href="Subpackage">套餐订购</a></li>
            <li><a href="Recharge.jsp">充值缴费</a></li>
            <li><a href="MyOrder.jsp">我的订单</a></li>
            <li><a href="MyComplaint.jsp">我的投诉</a></li>
            <li><a href="MyRepair.jsp">我的报修</a></li>
            <li><a href="Account_cancellation.jsp">账号注销</a></li>
        </ul>
    </div>
    <div class="right">

        <div class="container">
            <h2>账单</h2>
            <table>
                <thead>
                <tr>
                    <th>账单号</th>
                    <th>订单号</th>
                    <th>金额</th>
                    <th>支付方式</th>
                    <th>创建日期</th>
                    <th>修改日期</th>
                </tr>
                </thead>
                <tbody id="bill-list">
                <!-- 动态生成账单列表 -->
                <% if (billList != null) {
                    for (Bill bill : billList) { %>
                    <tr>
                        <td><%= bill.getBillID() %>
                        </td>
                        <td><%= bill.getOrderID() %>
                        </td>
                        <td><%= bill.getPrice() %>
                        </td>
                        <td><%= bill.getPaymentMethod() %>
                        </td>
                        <td><%= bill.getCreatedDate() %>
                        </td>
                        <td><%= bill.getModifiedDate() %>
                        </td>
                    </tr>
                    <% }
                } %>
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>
